from django.conf import settings
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
class SecretOauth(object):
    def __init__(self):
        self.serializer = Serializer(secret_key=settings.SECRET_KEY, expires_in=24 * 14 * 3600)
    # 1.加密
    def dumps(self, data):

        result = self.serializer.dumps(data)
        return result.decode()

    # 2.解密
    def loads(self, data):
        result = self.serializer.loads(data)
        return result